<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
	<link rel="stylesheet" href="https://static.91haoka.cn/vant.css" />
    <link rel="stylesheet" href="https://cdn.91haoka.cn/vant.css"/>
	<link rel="stylesheet" href="https://unpkg.com/vant@2.12/lib/index.css" />
	<script src="https://unpkg.com/vue@2.6/dist/vue.min.js"></script>
	<script src="https://unpkg.com/vant@2.12/lib/vant.min.js"></script>
	<script src="https://static.91haoka.cn/vue.min.js"></script>
	<script src="https://static.91haoka.cn/vantall.js"></script>
	<script src="https://static.91haoka.cn/axios.min.js"></script>
	<script src="js/q.js"></script>
	<script src="./js/qiniu.min.js"></script>
	<script src="https://test91.91haoka.cn/html2canvas.min.js"></script>

	<link rel="stylesheet" type="text/css" href="https://static.91haoka.cn/all.css" />
</head>
<!-- 快手回调用 -->
<script type="text/javascript">
	(function (root) {
		var ksscript = document.createElement('script');
		ksscript.setAttribute('charset', 'utf-8');
		ksscript.src = '//p2-yx.adkwai.com/udata/pkg/ks-ad-trace-sdk/ks-trace.3.2.0.min.js';
		var s = document.getElementsByTagName('script')[0];
		s.parentNode.insertBefore(ksscript, s);
	})(window);
</script>
<style type="text/css">
	.t_wind {
		width: 100vw;
		height: 100vh;
		position: fixed;
		display: flex;
		align-items: center;
		left: 0;
		top: 0;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 99;
	}

	* {
		box-sizing: border-box;
		font-family: 'PingFang SC';
	}

	.p1 {
		height: 1.3rem;
	}

	.p1 img {
		width: 100%;
		border-radius: 0.1rem;
	}

	.t1 {
		font-size: 0.28rem;
		color: #2D3038;
	}

	.btnxx {
		background: #005AFF;
		border-radius: 0.6rem;
		color: white;
		display: flex;
		justify-content: center;
		align-items: center;
		
	}

	.btnx {
		background: #FF3400;
		border-radius: 0.6rem;
		color: #fff;
		font-weight: bold;
		margin-top: 0.15rem;
		width: 1.7rem;
		padding: 0.2rem 0rem;
		text-align: center;
	}

	.p2 img {
		width: 0.34rem;
	}

	.t2 {
		font-size: 0.22rem;
		margin-top: 0.05rem;
	}

	.li {
		margin-top: 0.2rem;
		background: white;
		border-radius: 0.2rem 0.2rem 0 0;
		padding: 0.2rem 0.2rem 0 0.1rem;
	}

	.act {
		color: #FF3400;
	}

	.van-tab {
		min-width: 25%;
		max-width: 25%;
	}

	.youse .van-tabs__nav {
		background: #F3F3F5 !important;
		margin-bottom: 0.2rem;
	}

	.share_class {
		cursor: pointer;
		z-index: 9999999999999999999999999999999999999999999999999999;
		background: white;
		height: 50px;
		width: 50px;
		display: flex;
		justify-content: center;
		align-items: center;
		position: absolute;
		border-radius: 50%;
		top: 296px;
		right: 20px;
		box-shadow: 0 3px 9px #A5B3BF;
	}

	.package_list {
		display: flex;
		justify-content: space-between;
	}

	.age_price {
		display: flex;
		justify-content: space-around;
	}

	.van-cell {
		background: #F7F7F7;
	}

	.moban_one .van-tabs__line {
		background: white;
	}

	.catname_show {
		font-size: 0.36rem;
		font-weight: bold;
	}

	.van-tabs__wrap {
		border-radius: 0.3rem 0.3rem 0 0;

	}

	.van-hairline--top-bottom::after {
		border-width: 0;
	}
	.housing_contaienr{
		width: 100%;
		height: 100%;
		background-color: red;
	}

</style>

<body>
	<div id="app" style="background: #F6FAFF; min-height:100vh;padding: 0 30px;" v-cloak>

				<div style="width:100%;display:flex;justify-content:center;flex-direction: column;align-items: center;">

					<div style="display:flex;justify-content: center;width:100%">
						<div
						id="contenthp"
							style="background: #fff; border-radius:0.3rem; overflow: hidden;margin-top:1rem;width: 100%;height:100%">
							<div style="width: 100%;">
								<img :src="fourValue.haibaoImg||'https://91haoka.cn/gth/static/img/kenan.jpg' "
									style="width: 100%; border-radius:0.3rem;height:345px" />
							</div>
							<div class="flex" style="display:flex;background: white;" >
								<div style="width: 60%; padding: 0.3rem;margin-top:0.1rem;background: white;">
									<div :style="{fontSize: '0.28rem',color:fourValue.colorValue}">{{fourValue.content}}
									</div>
									<div class="flexc" style="padding: 0.2rem 0;">
										<!-- <div>
											<img src="https://gperson.gantanhaokeji.top/1706494446720ofbezyz9ppv.png"
												style="width: 0.4rem; height: 0.4rem; border-radius: 0.2rem;" />
										</div> -->
										<div style=" font-size: 0.24rem; color: rgb(64, 66, 71);">
											{{infoValue.title}}的小店</div>
									</div>
									<div style="color: rgb(175, 179, 188); font-size: 0.2rem;">长按识别二维码进入下单链接</div>
								</div>
								<div style="width: 40%; padding: 0.3rem 0;background: white;">

									<img :src="img2"
										style="width: 1.5rem; height: 1.5rem;margin-top:0.2rem;margin-left:0.5rem" />
								</div>
							</div>
						</div>
					</div>
					<div class="flex" style="display:flex;justify-content: space-between; margin-top: 0.6rem;width:100%">

						<div @click="shengchengtupian()"
							style="width: 2.6rem; height: 0.8rem; font-size: 14px; background: #E4EDFF;  cursor: pointer; color: #005AFF; border-radius: 0.4rem;"
							class="flexcc">保存照片</div>
						<div  @click="fuzhi()" style="width: 2.6rem; height: 0.8rem; font-size: 14px; background:#005AFF; color: white; cursor: pointer; border-radius: 0.4rem;"
							class="flexcc">复制链接</div>
					</div>
				</div>

            </div>

		<script>
			var h = document.documentElement.clientWidth / 7.5 + 'px';
			document.documentElement.style.fontSize = h;


			new Vue({
				el: '#app',
				data: function () {
					return {
						infoValue: {},
						fourValue: {
							haibaoImg: '',
							content: '',
							colorValue: ''
						},
						isshowwind: false,
						selectedTab: null,
						shareSwitch: false,
						all: {
							page: 1,
							page_size: 99,
							tab: "",
							cat: 0,
							sale_name: '',
							belong_address: "全国",

						},
						promoter_id:"",
						list: "",
						value: 5,
						img2: '',
						apis: '',
						luoji: true,
						fenleilist: "",
						xcx: true,
						moban: 2,
						json: [],
						dishilog: false,
						defaultIndex: 0,
						columns: ['全国', '北京市', '天津市', '河北省', '山西省', '内蒙古自治区', '辽宁省', '吉林省', '黑龙江省', '上海市', '江苏省', '浙江省', '安徽省', '福建省', '广西壮族自治区', '山东省', '山西省', '河南省', '湖北省', '湖南省', '广东省'
							, '海南省', '重庆市', '四川省', '贵州省', '云南省', '西藏自治区', '陕西省', '甘肃省', '青海省', '宁夏回族自治区', '新疆维吾尔自治区', '台湾省', '香港特别行政区', '澳门特别行政区']
					}
				},
				created() {
					this.all.tab = this.getUrlParam('id')
					if (this.all.tab == 38) {
						this.luoji = false
					}
					localStorage.setItem('tab', this.all.tab)
					this.promoter_id = this.getUrlParam('promoter_id')
					if (this.getUrlParam('promoter_id')) {
						localStorage.setItem('promoter_id', this.getUrlParam('promoter_id'))
					}
					if (this.getUrlParam('adid')) {
						localStorage.setItem('adid', this.getUrlParam('adid'))
					}
					if (this.getUrlParam('creativeid')) {
						localStorage.setItem('creativeid', this.getUrlParam('creativeid'))
					}
					if (this.getUrlParam('creativetype')) {
						localStorage.setItem('creativetype', this.getUrlParam('creativetype'))
					}
					if (this.getUrlParam('clickid')) {
						localStorage.setItem('clickid', this.getUrlParam('clickid'))
					}
					if (this.getUrlParam('source')) {
						if (this.getUrlParam('source') == 'xcx') {
							this.xcx = false
						}
					}

					if (this.getUrlParam('missionId')) {
						localStorage.setItem('missionId', this.getUrlParam('missionId'))
					}
					if (this.getUrlParam('orderId')) {
						localStorage.setItem('orderId', this.getUrlParam('orderId'))
					}
					if (this.getUrlParam('trafficsource')) {
						localStorage.setItem('trafficsource', this.getUrlParam('trafficsource'))
					}
					if (this.getUrlParam('imeiMD5')) {
						localStorage.setItem('imeiMD5', this.getUrlParam('imeiMD5'))
					}
					if (this.getUrlParam('callback')) {
						localStorage.setItem('callback', this.getUrlParam('callback'))
					}
					if (this.getUrlParam('event_id')) {
						localStorage.setItem('event_id', this.getUrlParam('event_id'))
					}
					if (this.getUrlParam('qz_gdt')) {
						localStorage.setItem('qz_gdt', this.getUrlParam('qz_gdt'))
					}
					if (this.getUrlParam('click_ext')) {
						localStorage.setItem('click_ext', this.getUrlParam('click_ext'))
					}
					if (this.getUrlParam('use_env')) {
						localStorage.setItem('use_env', this.getUrlParam('use_env'))
					}
					if (this.getUrlParam('mark_id')) {
						localStorage.setItem('mark_id', this.getUrlParam('mark_id'))
					}
					if (this.getUrlParam('bd_vid')) {
						localStorage.setItem('bd_vid', this.getUrlParam('bd_vid'))
					}
					if (this.getUrlParam('token')) {
						localStorage.setItem('token', this.getUrlParam('token'))
					}

					if (this.getUrlParam('track_id')) {
						localStorage.setItem('track_id', this.getUrlParam('track_id'))
					}
					if (this.getUrlParam('data_source_id')) {
						localStorage.setItem('data_source_id', this.getUrlParam('data_source_id'))
					}
					if (this.getUrlParam('account_id')) {
						localStorage.setItem('account_id', this.getUrlParam('account_id'))
					}
					if (this.getUrlParam('youku_track_id')) {
						localStorage.setItem('youku_track_id', this.getUrlParam('youku_track_id'))
					}
					if (this.getUrlParam('youku_creative_id')) {
						localStorage.setItem('youku_creative_id', this.getUrlParam('youku_creative_id'))
					}


					// localStorage.clear()
					// if(this.getUrlParam('juliang')){
					// 	localStorage.setItem('juliang',this.getUrlParam('juliang'))
					// }

					// if(this.getUrlParam('adid')){
					// 	localStorage.setItem('adid',this.getUrlParam('adid'))
					// }
					// if(this.getUrlParam('clickid')){
					// 	localStorage.setItem('clickid',this.getUrlParam('clickid'))
					// }
					// if(this.getUrlParam('creativeid')){
					// 	localStorage.setItem('creativeid',this.getUrlParam('creativeid'))
					// }
					// if(this.getUrlParam('creativetype')){
					// 	localStorage.setItem('creativetype',this.getUrlParam('creativetype'))
					// }

					// this.all.shop_id = this.getUrlParam('shop')
					// if(this.all.shop_id == 127837){
					// 	localStorage.setItem('shop_id',127837)
					// }else{
					// 	localStorage.clear('shop_id')
					// }


					//                this.getpro()
					// if(location.href.includes('local')){
					// 	this.apis = '/apis'
					// }
					if (location.href.includes('localhost') || location.href.includes('192.168.2.216')) {
						this.apis = '/apis'
					}
					this.getpeizhi()
					// 还原 axios.get(`/api/store/info?id=${this.all.tab}`) 短的

					// axios.get(`${this.apis}/api/store/info?id=${this.all.tab}`)
					axios.get(`/api/store/info?id=${this.all.tab}`)
						.then(response => {

							if (response.data.data != null) {
								this.infoValue = response.data.data
								document.title = response.data.data.title
								localStorage.setItem('title', response.data.data.title)
							}

						})
					// this.getfenlei()
				},
				computed: {
					youdima() {

						if (this.json.filter(item => item.type == 6).length > 0) {
							return {
								padding: "0 0 1.4rem 0"
							}
						}
					}
				},
				mounted() {
                    let url = location.origin + "/h5/index.html?id=" + this.getUrlParam('id')+'&promoter_id=' + this.promoter_id;
							document.title = "海报分享";
							var d = document.createElement("div");
							d.setAttribute("id", "erweimadiv");
							document.body.appendChild(d);
							var qrcode = new QRCode(document.getElementById("erweimadiv"), {
								text: url,
								width: 220,
								height: 220,
								colorDark: "#000000",
								colorLight: "#ffffff",
								correctLevel: QRCode.CorrectLevel.H
							});
							var canvas = document
								.getElementById("erweimadiv")
								.getElementsByTagName("canvas")[0];
							this.img2 = canvas.toDataURL("image/png");

							document.body.removeChild(d);
				},
				methods: {

					fuzhi: function (text) {
						let url = location.origin + "/h5/index.html?id=" + this.getUrlParam('id')+'&promoter_id=' + this.promoter_id;

						const clipboardData = window.clipboardData;
						if (clipboardData) {
							clipboardData.clearData();
							clipboardData.setData("Text", url);
							return true;
						} else if (document.execCommand) {
							const el = document.createElement("textarea");
							el.value = url;
							el.setAttribute("readonly", "");
							el.style.position = "absolute";
							el.style.left = "-9999px";
							document.body.appendChild(el);
							el.select();
							document.execCommand("copy");
							document.body.removeChild(el);
							vant.Toast('已复制');
							this.isshowwind = false
							return true;
						}
						return false;
					},

				getpeizhi: async function () {
					let wenjianjia = 'web-store'
					if (window.location.href.includes('storep.91haoka.cn') && this.apis == '') {
						wenjianjia = 'web-store'
					}
					if (window.location.href.includes('store.91haoka.cn') && this.apis == '') {
						wenjianjia = 'test-web-store'
					}
					if (window.location.href.includes('192.168.2.216')) {
						//   wenjianjia = 'web-page'
						wenjianjia = 'test-web-store'
					}
					if (window.location.href.includes('localhost')) {
						wenjianjia = 'web-store'
					}

					axios.get(`https://file.91haoka.cn/${wenjianjia}/${this.all.tab}.json?v=${Math.random()}`)
						// axios.get(`${this.apis}/storage/web-store/${this.all.tab}.json?v=${Math.random()}`)
						.then(response => {
							this.json = JSON.parse(response.data)
							console.log('this.json', this.json)

							if (!this.xcx) {
								this.json.forEach(item => {
									if (item.type == 5) {
										item.radio = 2
									}
								})
							}
							let share = this.json?.find(item => item.type == 8)
							console.log('share', share)
							if (!!this.json.find(item => item.type == 8)) {
								this.shareSwitch = share.shareSwitch
							} else {
								this.shareSwitch = false
							}
							this.json.forEach(item => {
								if (item.type == 7) {
									this.moban = item.moban
								}
								if (item.type == 9 && item.radioBelong == 2) {
									axios.get(`${this.apis}/api/ip-address/get`).then(response => {
										if (response.data.msg.code == 0) {
											if (response.data.data.addressComponent.province) {
												this.all.belong_address = response.data.data.addressComponent.province
												this.defaultIndex = this.columns.findIndex(item => item == this.all.belong_address)
												this.getshop()
												return
											}

										} else {
											if (response.data.data.addressComponent.province) {
												this.all.belong_address = '全国'
												this.defaultIndex = 0
												return;
											}
										}
									})
								}
								// this.moban = 2

								if (item.type == 10) {
									this.fourValue = item.fourValue
								}
							})
							this.getshop()

						})
				},
				getshop: function () {
					axios.get(`${this.apis}/api/page/list2`, { params: this.all })
						.then(response => {
							if (response.data.msg.code == 0) {
								this.list = response.data.data.data
								if (response.data.data.is_whole_country == '1') {
									this.all.belong_address = '全国'
									this.defaultIndex = 0
								}
								//  let fenleilist = []
								this.list.forEach(item => {

									axios.get("https://file.91haoka.cn/web-page/" + item.id + ".json")

										.then(response => {
											this.$set(item, 'min_page', JSON.parse(response.data).min_page)
											this.$set(item, 'max_page', JSON.parse(response.data).max_page)
										})

									if (item.json != '') {
										item.json = JSON.parse(item.json)
									}
									if (item.sell_point != null && item.sell_point) {
										item.sell_point = JSON.parse(item.sell_point)
									} else {
										item.sell_point = []
									}
								})
								console.log(this.list)
								//  this.fenleilist = [...new Set(fenleilist)]
								//  this.fenleilist.unshift('全部')

								this.total = response.data.data.total
							} else {
								this.$message.error(response.data.msg.info);
							}
						});
				},
				getUrlParam: function (name) {
					var query = window.location.search.substring(1);
					var vars = query.split("&");
					for (var i = 0; i < vars.length; i++) {
						var pair = vars[i].split("=");
						if (pair[0] == name) { return pair[1]; }
					}
					return (false);
				},
				base64ToBlob(code) {
					let parts = code.split(';base64,');
					let contentType = parts[0].split(':')[1];
					let raw = window.atob(parts[1]);
					let rawLength = raw.length;
					let uInt8Array = new Uint8Array(rawLength);
					for (let i = 0; i < rawLength; ++i) {
						uInt8Array[i] = raw.charCodeAt(i);
					}
					return new window.Blob([uInt8Array], { type: contentType });
				},

				getRandomChar: function (len = 11) {
					var x = "0123456789qwertyuioplkjhgfdsazxcvbnm" // 需要什么字符这里添加
					var tmp = ""
					var timestamp = new Date().getTime();
					for (var i = 0; i < len; i++) {
						tmp += x.charAt(Math.ceil(Math.random() * 100000000) % x.length);
					}
					return timestamp + tmp;
				},
				shengchengtupian: function () {
					vant.Toast('长按识别二维码进入下单链接');
					const element2 = document.getElementById('contenthp');
					html2canvas(element2, {
						useCORS: true, // 这个选项会自动处理跨域问题
						// scale: 1,//图片清晰度，越高越清楚，图片质量越大
						backgroundColor: null,//画出来的图片有白色的边框,不要可设置背景为透明色（null）
					}).then(canvas => {
						let weixin = false

						var ua = window.navigator.userAgent.toLowerCase();
						if (ua.match(/micromessenger/i) == 'micromessenger') {
							weixin = true
						}

						if (weixin) {
							let img = canvas.toDataURL('image/jpeg')
							let blob = this.base64ToBlob(img)  // 转码
							this.uploadok(blob)
						} else {
							// 将图像添加到DOM中
							var a = document.createElement("a");
							document.body.appendChild(a);
							a.href = canvas.toDataURL('image/png');
							a.download = "";
							a.click();
						}
					});
				},
				//上传文件
				uploadok: function (file, fileList) {




					axios.post(`${this.apis}/api/qiniu/token`,{bucket:"gth"})
						  	.then(response => {
						  	var qiniudata = new FormData();
						  		qiniudata.append('file', file);
						  		qiniudata.append('token',response.data.data);
						  		
						  		axios.post('https://upload.qiniup.com',qiniudata)
						  			.then(response => {
						  				location.href = 'https://pic.91haoka.cn/' + response.data.key
						  			})
						  })
					// let name = this.getRandomChar()

					// var that = this
					// axios.get(this.apis + `/api/system/qiniu/upload_token2`, {
					// 	params: { bucket: 'test91' }
					// })
					// 	.then(response => {
					// 		if (response.data.msg.code == 0) {
					// 			const observer = {
					// 				next(res) { },
					// 				error(err) { },
					// 				complete(res) {
					// 					location.href = 'https://gperson.gantanhaokeji.top/' + res.data
					// 				}
					// 			}
					// 			const observable = qiniu.upload(file, name, response.data.data, {}, {})
					// 			const subscription = observable.subscribe(observer) // 上传开始
					// 		} else {
					// 			vant.Toast(response.data.msg.info);
					// 		}
					// 	});
				},
				//获取商品
				getpro: function () {
					var that = this;
					axios.get('/web/page/list2', {
						params: this.all
					})
						.then(response => {
							if (response.data.msg.code == 0) {
								that.list = response.data.data.data
								that.list.forEach(item => {
									if (item.json != '') {
										item.json = JSON.parse(item.json)
									}
									console.log(item.json)
								})
							} else {
								that.$message.error(response.data.msg.info);
							}
						})
				},
			}
			});


		</script>
</body>

</html>